package beans;

import entities.ComprasDetalle;
import controllers.ComprasDetalleFacade;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

@ManagedBean(name = "comprasDetalleController")
@ViewScoped
public class ComprasDetalleController extends AbstractController<ComprasDetalle> implements Serializable {

    @EJB
    private ComprasDetalleFacade ejbFacade;

    public ComprasDetalleController() {
        super(ComprasDetalle.class);
    }

    @PostConstruct
    public void init() {
        super.setFacade(ejbFacade);
    }

    @Override
    protected void setEmbeddableKeys() {
        this.getSelected().getComprasDetallePK().setNroFactura(this.getSelected().getComprasCabecera().getComprasCabeceraPK().getNroFactura());
        this.getSelected().getComprasDetallePK().setCodProveedor(this.getSelected().getComprasCabecera().getComprasCabeceraPK().getCodProveedor());
    }

    @Override
    protected void initializeEmbeddableKey() {
        this.getSelected().setComprasDetallePK(new entities.ComprasDetallePK());
    }
}
